﻿using System;
using System.Collections.Generic;
using System.Text;
using MYTech.Oracle;
using MYTech.Utils;

namespace MYTech.Oracle
{
    public class Partition
    {
        public string TableName { get; set; }
        public DateTime Time { get; set; }
        public Partition(string tableName, string partitionName)
        {
            this.TableName = tableName;
            this.PartitionName = partitionName;
            string timeStr = partitionName.Substring(tableName.Length + 1);
            this.Time = TimeHelper.ToDateTime(timeStr, "yyMMddHHmm");
        }

        public PartitionType MinType
        {
            get
            {
                if (this.Time.Hour != 0)
                    return PartitionType.Hour;
                else
                    return PartitionType.Day;
            }
        }

        public string PartitionName { get; set; }

        public override string ToString()
        {
            return string.Format("{0} {1:yyyy-MM-dd HH:mm:ss}", this.TableName, this.Time);
        }
    }
}
